#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>


int main(int argc, const char* argv [])
{
    char buf[] = "www.baidu.com";

    struct hostent *hptr;
    hptr = gethostbyname(buf);
    if(hptr == NULL)
    {
	herror("gethostbyname");
	return -1;
    }

    char str[INET_ADDRSTRLEN];
    printf("sddress:%s\n", inet_ntop(hptr->h_addrtype, hptr->h_addr, str, sizeof(str)));

    endhostent();

    return 0;
}
